package com.woniuxy.service.impl;

import com.github.pagehelper.PageInfo;
import com.woniuxy.entity.dto.system.RoleDTO;
import com.woniuxy.entity.po.system.Role;
import com.woniuxy.mapper.RoleMapper;
import com.woniuxy.service.RoleService;
import com.woniuxy.util.PageHelperUtil;
import com.woniuxy.util.PageParam;
import com.woniuxy.util.ResponseData;
import lombok.AllArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
@AllArgsConstructor
public class RoleServiceImpl implements RoleService {
    private RoleMapper roleMapper;
    private PageHelperUtil pageHelperUtil;
    /** 
     * @Description: 
     * @Param: []
     * @return: com.woniuxy.util.ResponseData<?>
     * @Author: DirtyFlower
     * @Date: 2025/3/29
     */
    @Override
    public ResponseData<?> queryAll(PageParam<RoleDTO> pageParam) {
        PageInfo<?> pageInfo = pageHelperUtil.getPageInfo(pageParam, roleMapper::queryAll,RoleDTO::new);
        return ResponseData.ok(pageInfo);
    }


    @Override
    public void deleteRole(Long id) {
        roleMapper.deleteRole(id);
    }

    @Override
    public void batchDeleteRole(List<Long> ids) {
        roleMapper.BatchDeleteRole(ids);
    }

    @Override
    public void addRole(Role role) {
        roleMapper.addRole(role);
    }

    @Override
    public void updateRole(RoleDTO roleDTO) {
        roleMapper.updateRole(new Role(roleDTO));
    }

    @Override
    public Role queryIdInfo(Long id) {
        return roleMapper.queryIdInfo(id);
    }

    @Override
    public List<Role> queryRole() {
        return roleMapper.queryRole();
    }

}
